//
//  TKIMAlbumViewCell.m
//  TKPluginDemo
//
//  Created by liupm on 16/1/12.
//  Copyright © 2016年 liupm. All rights reserved.
//

#import "TKIMAlbumViewCell.h"

@implementation TKIMAlbumViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self drawView];
    }
    return self;
}


-(void)drawView
{
    [self.contentView addSubview:self.thumbImageView];
    [self.contentView addSubview:self.albumTitle];
    [self.contentView addSubview:self.photoCount];
}


-(void)setAlbum:(TKIMAlbumModel *)album
{
    self.thumbImageView.image = album.thumbImage;
    self.albumTitle.text = album.albumName;
    self.photoCount.text = [NSString stringWithFormat:@"%d",album.photoCount];
}


-(UIImageView *)thumbImageView
{
    if (!_thumbImageView)
    {
        _thumbImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 60, 60)];
    }
    return _thumbImageView;
}


-(UILabel *)albumTitle
{
    if (!_albumTitle)
    {
        CGFloat x = self.thumbImageView.frame.size.width+self.thumbImageView.frame.origin.x;
        _albumTitle = [[UILabel alloc] initWithFrame:CGRectMake(x+10, 0, TKIMPhotoScreenWidth*0.5, 80)];
        _albumTitle.font = [UIFont systemFontOfSize:18.0f];
    }
    return _albumTitle;
}

-(UILabel *)photoCount
{
    if (!_photoCount)
    {
        CGFloat x = TKIMPhotoScreenWidth-110;
        _photoCount = [[UILabel alloc] initWithFrame:CGRectMake(x, 0, 80, 80)];
        _photoCount.font = [UIFont systemFontOfSize:18.0f];
        _photoCount.textAlignment = NSTextAlignmentRight;
    }
    return _photoCount;
}

@end
